package mhcs.client;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.TabPanel;
import com.google.gwt.user.client.ui.VerticalPanel;

class MinConfigPopup extends PopupPanel {

    public MinConfigPopup() {
        super(true);
        g1 = new Grid(3, 5);
        g2 = new Grid(4, 4);
        g1.setStyleName("g2");
        g2.setStyleName("g2");
        tab = new TabPanel();
        
        dorm1 = new Image("images/Dormitory.jpg");
        san1 = new Image("images/Sanitation.jpg");
        plain1 = new Image("images/Plain.jpg");
        plain2 = new Image("images/Plain.jpg");
        plain3 = new Image("images/Plain.jpg");
        can1 = new Image("images/Canteen.jpg");
        air1 = new Image("images/Airlock.jpg");
        food1 = new Image("images/Food.jpg");
        con1 = new Image("images/Control.jpg");
        pow1 = new Image("images/Power.jpg");

        dorm2 = new Image("images/Dormitory.jpg");
        san2 = new Image("images/Sanitation.jpg");
        plain4 = new Image("images/Plain.jpg");
        plain5 = new Image("images/Plain.jpg");
        plain6 = new Image("images/Plain.jpg");
        can2 = new Image("images/Canteen.jpg");
        air2 = new Image("images/Airlock.jpg");
        food2 = new Image("images/Food.jpg");
        con2 = new Image("images/Control.jpg");
        pow2 = new Image("images/Power.jpg");

        dorm1.setPixelSize(40, 40);
        san1.setPixelSize(40, 40);
        plain1.setPixelSize(40, 40);
        plain2.setPixelSize(40, 40);
        plain3.setPixelSize(40, 40);
        can1.setPixelSize(40, 40);
        air1.setPixelSize(40, 40);
        food1.setPixelSize(40, 40);
        con1.setPixelSize(40, 40);
        pow1.setPixelSize(40, 40);

        dorm2.setPixelSize(40, 40);
        san2.setPixelSize(40, 40);
        plain4.setPixelSize(40, 40);
        plain5.setPixelSize(40, 40);
        plain6.setPixelSize(40, 40);
        can2.setPixelSize(40, 40);
        air2.setPixelSize(40, 40);
        food2.setPixelSize(40, 40);
        con2.setPixelSize(40, 40);
        pow2.setPixelSize(40, 40);

        
        g1.setWidget(0, 1, can1);
        g1.setWidget(0, 3, air1);
        g1.setWidget(1, 0, food1);
        g1.setWidget(1, 1, plain1);
        g1.setWidget(1, 2, plain2);
        g1.setWidget(1, 3, plain3);
        g1.setWidget(1, 4, san1);
        g1.setWidget(2, 1, pow1);
        g1.setWidget(2, 2, con1);
        g1.setWidget(2, 3, dorm1);
        
        g2.setWidget(0, 1, dorm2);
        g2.setWidget(1, 0, san2);
        g2.setWidget(1, 1, plain4);
        g2.setWidget(1, 2, can2);
        g2.setWidget(2, 0, air2);
        g2.setWidget(2, 1, plain5);
        g2.setWidget(2, 2, plain6);
        g2.setWidget(2, 3, food2);
        g2.setWidget(3, 1, con2);
        g2.setWidget(3, 2, pow2);
        
        VerticalPanel panel1 = new VerticalPanel();
        Button button1 = new Button("Choose as Configuration");
        button1.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                MHCS.dataSet.setConfiguration(1);
                MHCS.soundOutput.playSound6();
            }
        });
        panel1.add(g1);
        panel1.add(button1);
        
        VerticalPanel panel2 = new VerticalPanel();
        Button button2 = new Button("Choose as Configuration");
        button2.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                MHCS.dataSet.setConfiguration(2);
            }
        });
        panel2.add(g2);
        panel2.add(button2);
        
        VerticalPanel panel3 = new VerticalPanel();
        Button button3 = new Button("Choose Partition Configuration");
        button3.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                MHCS.dataSet.setConfiguration(3);
            }
            
        });
        panel3.add(button3);
        
        VerticalPanel panel4 = new VerticalPanel();
        Button button4 = new Button("Choose Wing Configuration");
        button4.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                MHCS.dataSet.setConfiguration(4);
            }
            
        });
        panel4.add(button4);

        tab.add(panel1, "Minimum 1");
        tab.add(panel2, "Minimum 2");
        tab.add(panel3, "Partition Configuration");
        tab.add(panel4, "Wing Configuration");
        tab.selectTab(0);
        
        add(tab);
    }

    private Grid g1;
    private Grid g2;
    
    private TabPanel tab;
    
    private Image dorm1;
    private Image san1;
    private Image plain1;
    private Image plain2;
    private Image plain3;
    private Image can1;
    private Image air1;
    private Image food1;
    private Image con1;
    private Image pow1;
    
    private Image dorm2;
    private Image san2;
    private Image plain4;
    private Image plain5;
    private Image plain6;
    private Image can2;
    private Image air2;
    private Image food2;
    private Image con2;
    private Image pow2;
}